package com.sskj.market.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.market.bean.ServicesBean;
import com.sskj.market.bean.ShopDetailsBean;
import com.sskj.market.ui.activity.CommodityDetailsActivity;


/**
 * @author Hey
 * Create at  2019/07/25
 */
public class CommodityDetailsPresenter extends BasePresenter<CommodityDetailsActivity> {

    public void getShopDetails(int id,boolean flag) {
        httpService.getShopDetails(id)
                .tag(this)
                .execute(new JsonCallBack<HttpData<ShopDetailsBean>>(flag?this:null) {
                    @Override
                    public void onSuccess(Response<HttpData<ShopDetailsBean>> response) {
                        mView.getShopDetailsSuccess(response.body().getData());
                    }
                });
    }

    public void getServices(CommodityDetailsPresenter presenter) {
        httpService.getKefu()
                .tag(this)
                .execute(new JsonCallBack<ServicesBean>(presenter, true) {
                    @Override
                    public void onSuccess(Response<ServicesBean> response) {
                        mView.getKeFuSuccess(response.body().getData().getService());
                    }
                });
    }
}
